package com.ysd.twocrm.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.ysd.twocrm.entity.StudentClass;
import com.ysd.twocrm.mapper.StudentClassMapper;
import com.ysd.twocrm.service.StudentClassService;
import com.ysd.twocrm.utils.LayuiUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

@Service
public class StudentClassServiceImpl implements StudentClassService {
@Autowired
    private StudentClassMapper studentClassMapper;

    @Override
    public LayuiUtils<StudentClass> STUDENT_CLASS_LAYUI_UTILS(Integer page, StudentClass s) {
        LayuiUtils<StudentClass> layuiUtils=new LayuiUtils<StudentClass>();
        Page<StudentClass> studentClassPage=new Page<StudentClass>(page,10);//分页
        QueryWrapper<StudentClass> queryWrapper=new QueryWrapper<StudentClass>();
        if(s.getStuClassDepartment()!=null&&s.getStuClassDepartment()!=""){
            queryWrapper.eq("s1.stuClassDepartment",s.getStuClassDepartment());//根据系查
        }
        if(s.getStuClass()!=null&&s.getStuClass()!=""){
            queryWrapper.like("s1.stuClass",s.getStuClass());//班级查询
        }
        if(s.getStuClassTeaId()!=null){
            queryWrapper.eq("s1.stuClassTeaId",s.getStuClassTeaId());//教员查询
        }
        if(s.getStuClassIstId()!=null){
            queryWrapper.eq("s1.stuClassIstId",s.getStuClassIstId());//辅导员查询
        }
        Page<StudentClass> stuClass = studentClassMapper.findStuClass(studentClassPage, queryWrapper);
        layuiUtils.setData(stuClass.getRecords());//数据
        layuiUtils.setCount(stuClass.getTotal());//长度
        return layuiUtils;
    }
}
